package pck_tramitedocu.pck_src.pck_utiles;

public class Cls_AlgoritmoEncriptacionSencilla {

    public static String encriptar(long num) {
            String tmp = "" + num;
        String cadena = "";
        int tam = tmp.length();
        for (int i = tam; i < 5; i++) {
            tmp = "0" + tmp;
        }
        for (int i = 0; i < 5; i++) {
            String caracter = "" + tmp.charAt(i);
            int valor = 97 + Integer.parseInt(caracter) + i;
            cadena = cadena + (char) valor;
        }
        return "EPS-" + cadena.toUpperCase();
    }

    public static String desencriptar(String cadena) {
        String[] dat = cadena.split("-");
        cadena = dat[1].toLowerCase();
        String retorno = "";
        for (int i = 0; i < 5; i++) {
            int valor = cadena.charAt(i) - 'a' - i;
            retorno = retorno + "" + valor;
        }
        return retorno;
    }
}